<template>
	<view class="wrap-redbag-nav">
		<view class="nav-bg flex">
			<block v-for="(item, index) in articleCate" :key="index">
				<view class="nav-tem flex column align-center just-center" @click="onNav(item)">
					<image class="icon" :src="$getImageURL(item.image)" />

					<view class="name f-30">{{ item.name }}</view>
				</view>
			</block>
		</view>

		<view class="redbag-bg flex align-center just-center" @click="$jump.to('/pages/home/article/redSquare')">
			<image class="img" mode="widthFix" lazy-load :src="$getImageURL(redBagImg)" />
		</view>

		<view class="category-bg flex">
			<block v-for="(item, index) in categoryList" :key="index">
				<view class="category-item flex column align-center just-center" @click="onCateItem(item)">
					<image class="icon" :src="$getImageURL(item.image)" />

					<view class="name f-28">{{ item.name }}</view>
				</view>
			</block>

			<view class="category-item flex column align-center just-center" @click="onMoreCategory" v-if="categoryList.length === 9">
				<image class="icon" :src="$staticImagePath('template/gdfl.png')" />

				<view class="name f-28">更多分类</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "redbagNav",
		props: {
			/**
			 * 红包广场图
			 */
			redBagImg: {
				type: String,
				default: "",
			},
			/**
			 * 分类列表
			 */
			categoryList: {
				type: Array,
				default: [],
			}
		},
		data() {
			return {
				articleCate: [], //文章分类
			};
		},
		mounted() {
			this.getArticleCategory();
		},
		methods: {
			/**
			 * 导航跳转
			 */
			onNav(item) {
				if (this.$filters.onActivityAlert(item)) {
					this.$jump.to(`/pages/home/article/list?title=${item.name}&parent_id=${item.id}`);
				}
			},
			/**
			 * 分类点击
			 */
			onCateItem(item) {
				this.$jump.to(`/pages/business/list?id=${item.id}&name=${item.name}`)
			},
			/**
			 * 更多分类
			 */
			onMoreCategory() {
				this.$jump.to("/pages/business/list");
			},

			/**
			 * 获取文章分类
			 */
			getArticleCategory() {
				this.$commonNetwork.getArticleCategoryList("0", (list) => {
					this.articleCate = list;
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.wrap-redbag-nav {
		width: 100%;
		background-color: white;
		overflow: hidden;
		border-top-left-radius: 40rpx;
		border-top-right-radius: 40rpx;
		padding-bottom: 30rpx;

		.nav-bg {
			width: 100%;
			padding: 25rpx 0rpx;
			overflow: hidden;

			.nav-tem {
				flex: 1;
				gap: 15rpx;

				.icon {
					width: 100rpx;
					height: 100rpx;
				}

				.name {
					color: #454545;
				}
			}
		}

		.redbag-bg {
			width: 100%;
			overflow: hidden;

			.img {
				width: 700rpx;
				height: auto;
			}
		}

		.category-bg {
			margin-top: 24rpx;
			width: 100%;
			overflow: hidden;
			flex-wrap: wrap;

			.category-item {
				width: 20%;
				overflow: hidden;
				gap: 12rpx;
				margin-bottom: 20rpx;

				.icon {
					width: 100rpx;
					height: 100rpx;
				}

				.name {
					color: #666666;
				}
			}
		}
	}
</style>